package com.example.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum CouponTypeEnum implements BaseEnum{
    /**
     * 枚举
     */
    PRICE_DISCOUNT(0, "满减"),
    RATE_DISCOUNT(1, "折扣"),
    NO_THRESHOLD(2, "无门槛");
    @EnumValue
    private final int value;
    private final String desc;


    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static CouponTypeEnum of(Integer value) {
        if (value == null) {
            return null;
        }
        for (CouponTypeEnum status : values()) {
            if (status.value == value) {
                return status;
            }
        }
        return null;
    }

    public static String desc(Integer value) {
        CouponTypeEnum status = of(value);
        return status == null ? "" : status.desc;
    }
}
